/**
 * 公共组件封装的全局使用
 */
/**
 * 全局注册公共组件
 * @param {Object} Vue
 */

export default {
  install(Vue) {
    let modules = import.meta.glob("../components/**/index.vue");
    let ignoreList = [];
    Object.keys(modules).forEach((file) => {
      let fileNameReg = /(?<=\/)([a-zA-Z-]+)/g;
      let fileName = file.match(fileNameReg); //--/BaseAce/index
      let name = "";
      if (!ignoreList.includes(fileName[fileName.length - 2])) {
        if (fileName.includes("index")) {
          name = fileName[fileName.length - 2];
          ignoreList.push(name);
        } else {
          name = fileName[fileName.length - 1];
        }
        Vue.component(name, modules[file]);
      }
    });
  }
};
